import { EnumBjlResult } from "@/models/enums/EnumBjlResult";
import { RoundInfo, RecmInfo } from "../ExecutePlan";
import { IMoneyStrategy } from "../IMoneyStrategy";


export class FixedMoneyStrategy implements IMoneyStrategy {
    strategyName: string = "";
    debugCompoenent: string = "";
    recmV: EnumBjlResult = EnumBjlResult.U;
    recmMoney: number = 0;
    orecmV: EnumBjlResult = EnumBjlResult.U;
    orecmMoney: number = 0;
    defaultMoney: number = 0;

    constructor(name: string, defaultMoney: number) {
        this.strategyName = name;
        this.defaultMoney = defaultMoney;
    }

    toMoney(roundInfo: RoundInfo, recmInfo: RecmInfo, userRecm: RecmInfo, baseMoney: number): [EnumBjlResult, number] {
        this.orecmV = roundInfo.userRecm;
        this.orecmMoney = this.defaultMoney;
        if (this.orecmV != EnumBjlResult.U && roundInfo.reverse) {
            this.recmV = this.orecmV == EnumBjlResult.Z ? EnumBjlResult.X : EnumBjlResult.Z;
        }
        else{
            this.recmV = this.orecmV;
        }
        this.recmMoney = this.orecmMoney;
        return [this.recmV, this.recmMoney];
    }
    showMoney(roundInfo?: RoundInfo): [EnumBjlResult, number] {
        if (roundInfo) {
            if (this.orecmV != EnumBjlResult.U && roundInfo.reverse) {
                this.recmV = this.orecmV == EnumBjlResult.Z ? EnumBjlResult.X : EnumBjlResult.Z;
            }
            else {
                this.recmV = this.orecmV;
            }
        }
        return [this.recmV, this.recmMoney];
    }
    resetStrategy(): void {
        this.recmV = EnumBjlResult.U;
        this.recmMoney = 0;
        this.orecmV = EnumBjlResult.U;
        this.orecmMoney = 0;
    }
    resetRecm(): void {
        this.recmV = EnumBjlResult.U;
        this.recmMoney = 0;
    }
    copyValue(valueObj: any): void {
        let obj = valueObj as FixedMoneyStrategy;
        if (obj) {
            //复制
            this.recmV = obj.recmV;
            this.recmMoney = obj.recmMoney;
            this.orecmV = obj.orecmV;
            this.orecmMoney = obj.orecmMoney;
        }
    }

}